package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.category.CategoryPageDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import com.sky.vo.CategoryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @Author 褚金龙
 * @Date 2024/8/31 20:58
 */
@Mapper
public interface CategoryMapper {
    /**
     * 分页查询
     * @param categoryPageDTO
     * @return
     */
    public Page<Category> page(CategoryPageDTO categoryPageDTO);

    /**
     * 按id查询
     * @return
     */
    @Select("select*from category where id=#{id}")
    CategoryVO queryCategory(Integer id);

    /**
     * 修改分类
     * @param category
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateCategoryMapper(Category category);

    /**
     * 修改状态
     * @param status
     * @param id
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateStatusMapper(Integer status,Integer id);

    /**
     * 删除分类
     * @param id
     */
    @Delete("delete from category where id=#{id}")
    void deleteCategoryMapper(Integer id);

    /**
     * 添加分类
     * @param category
     */
    @AutoFill(value = OperationType.INSERT)
    void insertCategoryMapper(Category category);
}
